package org.szy.core.common.config;

import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Init;
import org.noear.solon.web.staticfiles.StaticMappings;
import org.noear.solon.web.staticfiles.repository.FileStaticRepository;
import org.szy.core.common.prop.FileProperties;

/**
 * 静态资源配置
 *
 * @author 孙志阳
 * @date 2022-08-19
 * @since 1.0.0
 **/
@Configuration
public class ResourcesConfig {

    @Init
    public void init() {
        //  添加本地绝对目录
        String localFilePrefix = FileProperties.localFilePrefix;
        if (!localFilePrefix.startsWith("/")) localFilePrefix = "/" + localFilePrefix;
        if (!localFilePrefix.endsWith("/")) localFilePrefix = localFilePrefix + "/";
        StaticMappings.add(localFilePrefix, new FileStaticRepository(FileProperties.localFilePath));
    }

}
